﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ProjectMadaktariMVC.Models.Procedure>" %>
<% 
    ProjectMadaktariMVC.Models.Episode episode = (ProjectMadaktariMVC.Models.Episode)ViewData["episode"];

    using (Html.BeginForm())
    using (var db = ProjectMadaktariMVC.Models.DBFactory.CreateContext())
    {
        Response.Write("<div id=\"procedureForm\">");
        {
            Response.Write("<div id=\"Procedure\">");
            {
                //Response.Write("<input type=\"submit\" value=\"Save\" />");
                //Response.Write(Html.ActionLink("Cancel", "ViewEpisode", "Patient", null, null, "Procedure", new { EpisodeId = episode.Id, PatientId = episode.PatientId }, null));

                Response.Write("<h2>Edit Procedure</h2>");
                
                Response.Write("<div class=\"form_block\">");
                Response.Write("<span class=\"form_label\"><label for=\"date\">Procedure Date</label></span>");
                Response.Write(Html.TextBox("date", Model.Date == null ? "" : ((DateTime)Model.Date).ToString("MM/dd/yyyy"), new { @class = "datefield" }));
                Response.Write("</div>");

                Response.Write("<div class=\"form_block\">");
                Response.Write("<span class=\"form_label\"><label for=\"procedureTypeID\">Procedure</label></span>");
                Response.Write(ProjectMadaktariMVC.Helpers.ConfigurationHelper.ProcedureDropDown(db, "procedureTypeID", Model.ProcedureTypeId));
                Response.Write("</div>");

                Response.Write("<div class=\"form_block\">");
                Response.Write("<span class=\"form_label\"><label for=\"Anesthesia\">Anesthesia</label></span>");
                Response.Write(ProjectMadaktariMVC.Helpers.ConfigurationHelper.AnesthesiaRadioButtons(db, "Anesthesia", Model.Anesthesia));
                Response.Write("</div>");

                Response.Write("<div class=\"form_block\">");
                Response.Write("<span class=\"form_label\"><label for=\"AnesthesiaDuration\">Anesthesia Duration</label></span>");
                Response.Write(Html.TextBox("AnesthesiaDuration", Model.AnesthesiaDuration));
                Response.Write("</div>");

                Response.Write("<div class=\"form_block\">");
                Response.Write("<span class=\"form_label\"><label for=\"surgeonID\">Surgeon</label></span>");
                Response.Write(ProjectMadaktariMVC.Helpers.ConfigurationHelper.SurgeonDropDown(db, "surgeonID", Model.SurgeonId));
                Response.Write("</div>");

                Response.Write("<div class=\"form_block\">");
                Response.Write("<span class=\"form_label\"><label for=\"complications\">Surgical Complications</label></span>");
                Response.Write(ProjectMadaktariMVC.Helpers.ConfigurationHelper.SurgicalComplicationsRadioButtons(db, "complications", Model.Complications));
                Response.Write("</div>");

                Response.Write("<div class=\"form_block\">");
                Response.Write("<span class=\"form_label\"><label for=\"caseComments\">Case Comments</label></span>");
                Response.Write(Html.TextArea("caseComments", Model.CaseComments, new { cols = "45", rows = "5" }));
                Response.Write("</div>");

                Response.Write("<div class=\"form_block\">");
                Response.Write("<span class=\"form_label\"><label for=\"imageFindings\">Post-op Imaging</label></span>");
                Response.Write(Html.TextArea("imageFindings", Model.ImageFindings, new { cols = "45", rows = "5" }));
                Response.Write("</div>");

                Response.Write("<input type=\"submit\" value=\"Save\" />");
                Response.Write(Html.ActionLink("Cancel", "ViewEpisode", new { EpisodeId = episode.Id, PatientId = episode.PatientId }));
            }
            Response.Write("</div>");
        }
        Response.Write("</div>");
    }
%>
<script type="text/javascript">
    $(function () {
        $(".datefield").datepicker();
    });
</script>
